package com.newvpn.fastbest.zenith.utils;

import android.os.Bundle;

import com.google.android.gms.ads.AdValue;
import com.google.android.gms.ads.AdapterResponseInfo;
import com.newvpn.fastbest.zenith.beans.netbeans.BaseResponse;
import com.newvpn.fastbest.zenith.beans.reqbeans.ReqAdValue;
import com.newvpn.fastbest.zenith.net.NetService;

import java.util.UUID;

import io.reactivex.rxjava3.core.Observable;

public class AdValueUpload {

    public static void adValueReport(AdValue adValue, String adUnitId, AdapterResponseInfo loadedAdapterResponseInfo, Bundle extras, int type, String scence, UUID uuid) {
        ReqAdValue info = new ReqAdValue();
        info.adType = type;
        info.adScenes = scence;
        info.valueMicros = adValue.getValueMicros();
        info.adSourceName = loadedAdapterResponseInfo.getAdSourceName();
        info.currencyCode = adValue.getCurrencyCode();
        info.recordUUID = UUID.randomUUID().toString();
        info.showUUID = uuid.toString();
        info.country = DeviceUtils.getCountry();
        info.adUnitId = adUnitId;
        info.precision = adValue.getPrecisionType();;
        info.deviceID = DeviceUtils.getDeviceId();
        info.callbackTime = System.currentTimeMillis();
        Observable<BaseResponse<Void>> observable = NetService.INSTANCE.postAdCost(info);
        observable.subscribe(
                response -> {
                    if (response.code == 0){

                    }
                    //Log.e("tag", "sucess");
                },
                throwable -> {
                    // 处理错误
                   // Log.e("tag", throwable.getMessage());
                }
        );
    }
}
